<!--《明细》搜索组建-->
<template>
    <div class="details-search-wrapper" :id="boxId" ref="searchInput">
        <a-input autofocus="autofocus" style="position:relative;z-index:66" :placeholder="`请选择${componentArray[componentName].name}`" ref="inputBox" v-model="inputValue" @focus="showModal" @change="inputSearch" @pressEnter="clickEnter" />
        <div class="search-wrapper" ref="searchWrapper" v-show="tableShow">
            <!-- 多选 -->
            <a-table class="much-table" v-if="componentName=='accounting'" :row-selection="{ selectedRowKeys: selectedKeys, onChange: onSelectChange }" :scroll="{x:600,y:180}" :columns="columns" :data-source="tableData" bordered :pagination="pagination" :loading="isRun">
                <template slot="footer">
                    <div class="much-footer">
                        <a-button type="primary" @click="handleClick">确认</a-button>
                    </div>
                </template>

            </a-table>
            <!-- 单选 -->
            <a-table v-else :scroll="{x:600,y:180}" :columns="columns" :rowClassName="rowClassName" :data-source="tableData" :customRow="customClick" bordered :pagination="pagination" :loading="isRun">

            </a-table>
        </div>
        <div class="edit-mask" @click="closeSearch" style="position:fixed;width:100%;height:100%;top:0;left:0;bottom:0;right:0;background:rgba(254,56,89,0);z-index:62">

        </div>
    </div>
</template>
<script>

import { getAction } from "@/api/manage";
import { mapState } from "vuex";

export default {
    props: {
        inputValue: {
            type: String,
        },
        componentName: {
            type: String,
        },
        boxId: {
            type: String, //当前容器id
        },
        record: {
            type: Object,
            default: {}
        },
        inputType: Number,//bom中是否可选
    },
    computed: {
        ...mapState({
            wherehouseId: state => state.order.wherehouseId,
        }),
    },
    data () {
        return {
            codesName: null,         //当前组建名称
            columns: [],
            pagination: {
                current: 1,
                pageSize: 10,
                total: 0,
                size: 'small',
                onChange: (page, pageSize) => {
                    this.postData.current = page;
                    this.pageList();
                }
            },
            postData: {},
            tableData: [],
            customClick: (record, index) => ({
                on: {
                    click: (event) => {
                        event.preventDefault();
                        this.clickEnter('click', record);
                    },
                },
            }),
            tableShow: false,
            isRun: false,
            setTime: null,  //延迟请求
            id: null,       //当前选择的搜索id
            tableBody: null,
            apiUrl: null,
            inputValue: '',  //输入框的值
            componentArray: {
                office: {
                    "name": "生产车间",
                    "code": "office",
                },
                teamList: {
                    "name": "班组",
                    "code": "teamList",
                },
                gxDetailsKey: {
                    "name": "工序",
                    "code": "gxDetailsKeyName",
                },
                processDetails: {
                    "name": "工序",
                    "code": "processDetailsName",
                },
                clubUser: {
                    "name": "姓名",
                    "code": "clubUserName",
                },
                team: {
                    "name": "班组",
                    "code": "teamName",
                },
                process: {
                    "name": "工序名称",
                    "code": "workName",
                },
                procedure: {
                    "name": "工序名称",
                    "code": "workName",
                },
                bomVersion: {
                    "name": "子件BOM",
                    "code": "bomVersion",
                },
                processRoute: {
                    "name": "工艺路线",
                    "code": "processRoute",
                },
                warehouse: {
                    "name": "仓库",
                    "code": "warehouse",
                },
                workerName: {
                    "name": '工人',
                    "code": 'workerName'
                },
                accounting: {//会计科目多选
                    "name": '会计科目',
                    "code": 'accounting'
                },
                accountingRadio: {//会计科目单选
                    "name": '会计科目',
                    "code": 'accountingRadio'
                },
                bank: {
                    "name": "银行名称",
                    "code": "bank"
                },
                crm: {
                    "name": '客户',
                    "code": "crm"
                },
                supplie: {
                    "name": '供应商',
                    "code": "supplie"
                },
                project: {
                    "name": '项目',
                    "code": "project"
                },
                currency: {
                    "name": "币种",
                    "code": "currency"
                },
                location: {
                    "name": '货位',
                    "code": "location"
                },
                inventoryCategory: {
                    "name": '存货分类',
                    "code": 'inventoryCategory'
                },
                clearmethod: {
                    "name": "结算方式",
                    "code": 'clearmethod'
                },
                invoiceType: {
                    "name": '发票类型',
                    "code": 'invoiceType'
                },
                contractPhase: {
                    "name": '合同阶段',
                    "code": 'contractPhase'
                },
                contractTerms: {
                    "name": '条款编码',
                    "code": 'contractTerms'
                },
                voucherCode: {
                    "name": '业务对象',
                    "code": 'voucherCode'
                },
                voucherField: {
                    "name": '业务对象字段',
                    "code": 'voucherField'
                },
                barcodeAttrCode: {
                    "name": '条码属性',
                    "code": 'barcodeAttrCode'
                }
            },
            selectedKeys: [],
            selectedRows: [],

            voucherCode: "",//业务对象（条码属性）
        }
    },
    created () {
        if (this.componentName == 'accountingRadio') {
            //当科目名称获取焦点的时候装换成 科目code
            this.inputValue = this.record.accountingCode;
        }

        if (this.componentName == 'voucherField') {
            //当业务对象字段获取焦点的时候装换成 业务对象
            this.voucherCode = this.record.voucherTypeCode;
        }

        this.checkSearch();


    },

    mounted () {
        if (this.record.focus) {
            //组建显示默认获取焦点
            this.$refs.inputBox.focus();
        }
    },




    methods: {
        pageList () {
            if (!this.isRun) {
                this.isRun = true;
                console.log("请求地址：", this.apiUrl, '请求数据:', this.postData)

                getAction(this.apiUrl, this.postData).then(response => {
                    if (response.code === 200) {

                        //某些接口没有分页  
                        let data = [];
                        if (this.componentName == 'processDetails' || this.componentName == 'gxDetailsKey' ||
                            this.componentName == 'inventoryCategory' || this.componentName == 'contractTerms' ||
                            this.componentName == 'voucherCode' || this.componentName == 'voucherField' ||
                            this.componentName == 'barcodeAttrCode' || this.componentName == 'procedure') {
                            this.tableData = response.data;
                            this.isRun = false;
                            return;
                        }

                        //需要分页处理
                        const { records, total, current, size } = response.data;
                        let page = {
                            total: total,
                            pageSize: size,
                            current: current,
                        }
                        this.pagination = Object.assign(this.pagination, page);
                        //返回值处理
                        let val = this.componentName;
                        switch (val) {
                            case 'office'://部门
                                records.forEach(element => {
                                    this.$set(element, 'name', element.officeName);
                                });
                                break;

                            case 'clubUser'://车间员工
                                records.forEach(element => {
                                    this.$set(element, 'name', element.empName);
                                });
                                break;


                            case 'workerName'://业务员
                                records.forEach(element => {
                                    this.$set(element, 'name', element.realName);
                                });
                                break;
                            case 'bomVersion'://子件bom
                                records.forEach(element => {
                                    this.$set(element, 'name', element.versionCode);
                                });
                                break;

                            case 'supplie'://建议供应商
                                records.forEach(element => {
                                    this.$set(element, 'name', element.crmName);
                                });
                                break;
                            default:
                                break;
                        }
                        let recData = records.map(v => {
                            return { ...v, key: v.id }
                        })
                        this.tableData = recData;
                        this.isRun = false;
                    }
                }).catch(error => { });
            }
        },
        showModal () {
            this.tableShow = true;
            this.codesName = this.componentName;
            this.boxId = this.componentName;
            this.$nextTick(() => {
                this.pageList();

                let w = document.body.clientWidth;//当前可视窗口宽度
                let searchBox = this.$refs.searchWrapper.getBoundingClientRect();
                let searchInput = this.$refs.searchInput.getBoundingClientRect();

                console.log('弹出框距离左侧距离:', searchBox, searchBox.right, w, searchInput)
                // if (searchInput.right + 40 >= w) { //右边溢出处理
                //     this.$refs.searchWrapper.style.left = -(searchBox.width - searchInput.width) + 'px';
                // } else if (searchInput.left < 360) { //左边溢出处理
                //     this.$refs.searchWrapper.style.left = 0 + 'px';
                // } else {
                //     this.$refs.searchWrapper.style.left = - searchInput.width + 'px'
                // }


                //采购到货单 || 采购退货单 || 生产完工单，明细中仓库的位置有所改变(弹框中的定位)
                if (this.$route.path == '/procurement/purchaseReturn' ||
                    this.$route.path == '/procurement/purchaseReceipt' ||
                    this.$route.path == '/production/management/productionOrder' ||
                    this.$route.path == '/production/management/productionFinish' ||
                    this.$route.path == '/inventory/bills/picking' ||
                    this.$route.path == '/production/productionPlan' ||
                    this.$route.path == '/sale/saleOrder') {
                    this.$refs.searchWrapper.style.left = searchInput.left + 'px';
                    this.$refs.searchWrapper.style.top = searchInput.top + 30 + 'px';
                    // this.$refs.searchWrapper.style.left = '0px';
                } else if (this.$route.path == '/finance/setting/financeTemplate') {
                    //凭证模板的弹窗
                    this.$refs.searchWrapper.style.left = searchInput.left + 'px';
                    this.$refs.searchWrapper.style.top = searchInput.top + 30 + 'px';
                } else if (this.$route.path == '/finance/setting/setInit') {

                } else {

                    this.$refs.searchWrapper.style.top = searchInput.top + 30 + 'px';
                    if (searchInput.right + 400 >= w) { //右边溢出处理
                        this.$refs.searchWrapper.style.right = '0px';
                    } else {
                        this.$refs.searchWrapper.style.left = searchInput.left + 'px';
                    }
                }

                if (this.record.accountingId && this.componentName == 'accounting') {
                    let array = this.record.accountingId.split(',');
                    let checks = [];
                    array.forEach(element => {
                        checks.push(Number(element))
                    });
                    console.log(checks);
                    if (this.componentName == 'accounting') {
                        this.selectedKeys = checks;
                    }
                }


                this.$refs.inputBox.focus();
            })
        },
        onclose () {
            this.tableShow = false;
        },
        closeSearch () {
            this.tableShow = false;
            if (this.inputValue) {
                // 1：代表没有清空选择框里面的数据
                this.$emit('clickItem', 1);
            } else {
                this.$emit('clickItem');
            }
        },
        inputSearch () {
            console.log('延迟请求')
            this.postData.searchKey = this.inputValue;
            this.postData.keyWord = this.inputValue;
            if (this.componentName == 'voucherCode') {
                this.postData.voucherTypeName = this.inputValue;
            } else if (this.componentName == 'voucherField') {
                this.postData.name = this.inputValue;
                this.postData.code = this.inputValue;
            }
            //延迟请求
            if (this.setTime) {
                clearTimeout(this.setTime)
            }
            this.setTime = setTimeout(() => {
                this.pageList();
            }, 500)
        },
        clickEnter (type, record) {
            //type == 'click' 表示点击表格事件
            let data = {};
            if (type == 'click') {
                data = Object.assign(record, { codesName: this.codesName })
                this.id = record.id;
            } else {
                if (this.tableData != '' && this.tableData != null) {
                    data = Object.assign(this.tableData[0], { codesName: this.codesName })
                    this.id = this.tableData[0].id;
                }

            }
            this.inputValue = data.name;

            this.$emit('clickItem', data);
            this.onclose();
        },
        checkSearch () {
            //当前搜索类型
            //team 班组档案
            let val = this.componentName;
            switch (val) {

                case 'office'://部门
                    this.apiUrl = '/system/office/page';
                    this.columns = [
                        { title: "编码", dataIndex: "officeCode", },
                        { title: "机构名称", dataIndex: "officeName", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        // officeCode: this.inputValue
                    }
                    break;

                case 'clubUser'://车间员工
                    this.apiUrl = '/sys/employee/pageSysEmployeeSimpleVo';
                    this.columns = [
                        // {
                        //     title: "工号",
                        //     dataIndex: "empNo",
                        //     align: 'center',
                        //     scopedSlots: {
                        //         customRender: "empNo",
                        //     },
                        // },
                        {
                            title: "姓名",
                            align: 'center',
                            dataIndex: "empName",
                            scopedSlots: {
                                customRender: "empName",
                            },
                        },
                        {
                            title: "部门",
                            align: 'center',
                            dataIndex: "officeName",
                            scopedSlots: {
                                customRender: "officeName",
                            },
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        // officeId: this.record.officeId
                    }
                    break;

                case 'teamList'://班组
                    this.apiUrl = '/erp/team/pageList';
                    this.columns = [
                        {
                            title: "班次编码",
                            dataIndex: "code",
                            align: 'center',
                            scopedSlots: {
                                customRender: "code",
                            },
                        },
                        {
                            title: "创建时间",
                            align: 'center',
                            dataIndex: "createDate",
                            scopedSlots: {
                                customRender: "createDate",
                            },
                        },
                        {
                            title: "部门名称",
                            align: 'center',
                            dataIndex: "officeName",
                            scopedSlots: {
                                customRender: "officeName",
                            },
                        },
                        {
                            title: "班组名称",
                            align: 'center',
                            dataIndex: "name",
                            scopedSlots: {
                                customRender: "name",
                            },
                        },
                        {
                            title: "备注",
                            align: 'center',
                            dataIndex: "remarks",
                            scopedSlots: {
                                customRender: "remarks",
                            },
                        },
                        {
                            title: "状态",
                            align: 'center',
                            dataIndex: "status",
                            customRender: (text) => {
                                if (text == 0) {
                                    return '停用';
                                } else if (text == 1) {
                                    return '正常';
                                }
                            },
                        }
                    ];

                    this.postData = {
                        // officeId: this.record.officeId
                    }
                    break;

                case 'processDetails':  //派工单=>工序明细    
                case 'gxDetailsKey':    //详细，明细
                    this.apiUrl = '/erp/processRoute/getDetailList';
                    this.columns = [
                        {
                            title: "工艺要求",
                            dataIndex: "processRequire",
                            align: 'center',
                        },
                        {
                            title: "检验方式",
                            align: 'center',
                            dataIndex: "inspectMethod",
                            customRender: (text) => {
                                if (text == 1) {
                                    return '免检';
                                } else if (text == 2) {
                                    return '过程检验';
                                } else if (text == 3) {
                                    return '完工检验';
                                }
                            },
                        },
                        {
                            title: "加工方式",
                            align: 'center',
                            dataIndex: "processMethod",
                            customRender: (text) => {
                                if (text == 1) {
                                    return '自制加工';
                                } else if (text == 2) {
                                    return '委外加工';
                                }
                            },
                        },
                        {
                            title: "质检标准",
                            align: 'center',
                            dataIndex: "qualityStandard",
                            scopedSlots: {
                                customRender: "qualityStandard",
                            },
                        },
                        {
                            title: "工序标识",
                            align: 'center',
                            dataIndex: "workFlag",
                            customRender: (text) => {
                                if (text == 1) {
                                    return '首工序';
                                } else if (text == 2) {
                                    return '尾工序';
                                } else if (text == 3) {
                                    return '中间工序';
                                }
                            },
                        },
                        {
                            title: "工序名称",
                            align: 'center',
                            dataIndex: "workName",
                        }

                    ];
                    this.postData = {
                        id: this.record.processRouteId,
                    }
                    this.pagination = false;
                    break;

                case 'team'://班组档案
                    this.apiUrl = '/erp/team/pageList';
                    this.columns = [
                        { title: "班组编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "班组名称", dataIndex: "name", width: "120", align: "left" },
                        { title: "所属机构", dataIndex: "officeName", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;

                case 'team'://班组档案
                    this.apiUrl = '/erp/team/pageList';
                    this.columns = [
                        { title: "班组编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "班组名称", dataIndex: "name", width: "120", align: "left" },
                        { title: "所属机构", dataIndex: "officeName", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'production'://生产线
                    this.apiUrl = '/erp/productionLine/pageList';
                    this.columns = [
                        { title: "生产线编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "生产线名称", dataIndex: "name", width: "120", align: "left" },
                        { title: "所属车间", dataIndex: "officeName", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'process'://工序档案
                    this.apiUrl = '/erp/workProcedure/pageList';
                    this.columns = [
                        { title: "工序编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "工序名称", dataIndex: "name", width: "120", align: "left" },
                        {
                            title: "加工方式", dataIndex: "processMethod", width: "120", align: "left", customRender: (text, row, index) => {
                                const type = ["自制加工", "委外加工"];
                                return type[text - 1];
                            }
                        },
                        {
                            title: "工资类型", dataIndex: "wagesType", width: "120", align: "left", customRender: (text, row, index) => {
                                const type = ["计件", "计时", "不核算"];
                                return type[text - 1];
                            }
                        },
                        { title: "合格品价格", dataIndex: "qualifiedPrice", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'procedure'://工序汇报单 （工序）
                    this.apiUrl = '/erp/processRoute/listProcessRouteAndPriceDetailVo';
                    this.columns = [
                        { title: "工序编码", dataIndex: "procedureCode", width: 60, align: "left" },
                        { title: "工序名称", dataIndex: "procedureName", width: 80, align: "left" },
                        {
                            title: "工资类型", dataIndex: "wagesType", width: 60, align: "center", customRender: (text, row, index) => {
                                const type = ["计件", "计时", "不核算"];
                                return type[text - 1];
                            }
                        },
                        { title: "工序顺序", dataIndex: "procedureOrder", width: 60, align: "center" },
                        // {
                        //     title: "加工方式", dataIndex: "processMethod", width: "120", align: "left", customRender: (text, row, index) => {
                        //         const type = ["自制加工", "委外加工"];
                        //         return type[text - 1];
                        //     }
                        // },
                        { title: "合格品价格", dataIndex: "qualifiedPrice", width: 80, align: "left" },
                        { title: "返修品价格", dataIndex: "reworkPrice", width: 80, align: "left" },
                        { title: "不合格品价格", dataIndex: "unqualifiedPrice", width: 90, align: "left" },
                        { title: "报废品价格", dataIndex: "scrapPrice", width: 80, align: "left" },

                        { title: "最新合格品价格", dataIndex: "lastQualifiedPrice", width: 100, align: "left" },
                        { title: "最新返修品价格", dataIndex: "lastReworkPrice", width: 100, align: "left" },
                        { title: "最新不合格品价格", dataIndex: "lastUnqualifiedPrice", width: 110, align: "left" },
                        { title: "最新报废品价格", dataIndex: "lastScrapPrice", width: 100, align: "left" },

                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        id: this.record.processRouteId,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'bomVersion'://子件BOM
                    this.apiUrl = '/bom/getList';
                    this.columns = [
                    { title: '版本号', dataIndex: 'versionCode', ellipsis: true, },
                        {
                        title: 'BOM类型', dataIndex: 'bomType', ellipsis: true,
                        customRender: (text, row, index) => {
                            return <span>{text == 1 ? '装配' : text == 2 ? '销售' : text == 3 ? '生产' : ''}</span>;
                        }
                    },
                    { title: '母件编码', dataIndex: 'inventoryCode', ellipsis: true, },
                    { title: '母件名称', dataIndex: 'inventoryName', ellipsis: true, },
                    { title: '创建日期', dataIndex: 'createDate', ellipsis: true, }];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        inventoryId: this.record.inventoryId ? this.record.inventoryId : "0"
                    }
                    break;
                case 'processRoute'://工艺路线
                    this.apiUrl = '/erp/processRoute/getList';
                    this.columns = [{ title: '编码', dataIndex: 'code', width: 75, ellipsis: true, },
                    { title: '名称', dataIndex: 'name', ellipsis: true, width: 80, ellipsis: true },
                    { title: '产品编码', dataIndex: 'inventoryCode', width: 80 },
                    { title: '产品名称', dataIndex: 'inventoryName', width: 80 },
                    { title: '规格型号', dataIndex: 'inventorySpecification', width: 80 },
                    {
                        title: '状态', dataIndex: 'status', width: 60,
                        customRender: (text, row, index) => {
                            return text == 1 ? '启用' : '禁用';
                        }
                    }];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        inventoryId: this.record.inventoryId ? this.record.inventoryId : "0",
                        status: 1,            //状态1:正常 0停用
                        examineStatus: 1,    //审核状态1:已审 0:未审
                    }
                    break;
                case 'workerName'://员工
                    this.apiUrl = '/sysUser/user/page';
                    this.columns = [
                        { title: "用户姓名", dataIndex: "realName" },
                        { title: "所属机构", dataIndex: "officeName", ellipsis: true, },
                        { title: "手机号", dataIndex: "mobile" },
                        { title: "电子邮箱", dataIndex: "email", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'accounting'://会计科目多选
                    this.apiUrl = '/erp/accounting/page';
                    this.columns = [
                        {
                            title: "科目编码",
                            dataIndex: "code",
                            key: "officeName",
                            align: "left",
                            width: 100
                        },
                        {
                            title: "科目名称",
                            dataIndex: "name",
                            key: "officeName",
                            align: "left",
                            width: 100,
                        }, {
                            title: "科目类型",
                            dataIndex: "accountingTypeName",
                            key: "officeName",
                            align: "left",
                            width: 100,
                        }, {
                            title: "余额方向",
                            dataIndex: "dcDirection",
                            key: "officeName",
                            align: "left",
                            width: 100,
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "借方" : "贷方";
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        // searchKey: this.inputValue
                    }
                    break;
                case 'accountingRadio'://会计科目单选
                    this.apiUrl = '/erp/accounting/page';
                    this.columns = [
                        {
                            title: "科目编码",
                            dataIndex: "code",
                            key: "officeName",
                            align: "left",
                            width: 100
                        },
                        {
                            title: "科目名称",
                            dataIndex: "treeNames",
                            key: "officeName",
                            align: "left",
                            width: 200,
                            customRender: (text, record, index) => {
                                return <span>{text && text.indexOf('/') != -1 ? text.replaceAll('/', '_') : text}</span>;
                            }
                            // customRender: (text, record, index) => {
                            //     if (record.depth != 1) {
                            //         let lelft = 8 * record.depth + "px";
                            //         let style = { marginLeft: lelft };
                            //         return <span style={style} >{text.replaceAll('/', '_')}</span>;
                            //     } else {
                            //         if (text) {
                            //             return text.replaceAll('/', '_');
                            //         } else {
                            //             return null;
                            //         }
                            //     }
                            // }
                        }, {
                            title: "科目类型",
                            dataIndex: "accountingTypeName",
                            key: "officeName",
                            align: "left",
                            width: 50,
                        }, {
                            title: "余额方向",
                            dataIndex: "dcDirection",
                            key: "officeName",
                            align: "left",
                            width: 50,
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "借方" : "贷方";
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: 1000,
                        searchKey: this.inputValue,
                        isEndNode: 1,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'warehouse'://仓库
                case 'warehouseNameKey': //预出苍库
                    let path = this.$route.path;
                    if (path == '/inventory/bills/purchaseIn' || path == '/inventory/bills/productIn' || path == '/inventory/bills/saleOut' || path == '/inventory/bills/materialOut') {
                        //表示是库存管理里的采购入库
                        this.apiUrl = '/in/warehouse/listMyOperationInWarehouses'
                    } else {
                        this.apiUrl = '/in/warehouse/pageList';
                    }

                    this.columns = [
                        { title: "仓库编码", dataIndex: "whCode", },
                        { title: "仓库名称", dataIndex: "whName", },
                        { title: "负责人", dataIndex: "whPerson" },
                        { title: "电话", dataIndex: "whTelephone" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'crm'://客户
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        // { title: "首拼码", dataIndex: "crmSimpleName" },
                        { title: "客户名称", dataIndex: "crmName", ellipsis: true, },
                        { title: "所属地区", dataIndex: "areaName", ellipsis: true, },
                        { title: "所属行业", dataIndex: "industry", ellipsis: true, },
                        { title: "联系地址", dataIndex: "address", ellipsis: true, },
                        // { title: "客户类型", dataIndex: "partnerClassId", ellipsis: true, scopedSlots: { customRender: "partnerClassCustomer" }},
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                        companyType: 'isCustomer'
                    }
                    break;
                case 'supplie'://供应商
                    // this.apiUrl = '/vendor/page';
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        // { title: "首拼码", dataIndex: "vendorPym", },
                        { title: "供应商编码", dataIndex: "crmNo", ellipsis: true, },
                        { title: "供应商名称", dataIndex: "crmName", ellipsis: true, },
                        // { title: "类型", dataIndex: "partnerClassId", scopedSlots: { customRender: "partnerClassId" }, },
                        { title: "联系地址", dataIndex: "address", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                        companyType: 'isSupplier'
                    }
                    break;
                case 'bank'://银行
                    this.apiUrl = '/erp/bankAccount/pageList';
                    this.columns = [
                        { align: "left", title: "账户名称", dataIndex: "accountName", width: "120" },
                        { align: "left", title: "账户类型", dataIndex: "accountType", width: "120", customRender: (text, record, index) => { return text == 1 ? '银行账号' : text == 2 ? '微信账号' : text == 3 ? '支付宝账号' : text == 4 ? '个人银行卡' : '' } },
                        { align: "left", title: "开户银行", dataIndex: "bankName", width: "120" },
                        { align: "left", title: "银行账号", dataIndex: "bankAccount", width: "120" },
                        { align: "left", title: "币种", dataIndex: "currencyName", width: "120" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'project'://项目
                    this.apiUrl = '/erp/project/pageList';
                    this.columns = [
                        { title: "项目编码", dataIndex: "code" },
                        { title: "项目名称", dataIndex: "name" },
                        { title: "所属部门", dataIndex: "department" },
                        { title: "负责人", dataIndex: "liablePersonNames" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'location'://货位
                case 'inventoryLocation'://货位
                    this.apiUrl = '/in/inventoryLocation/pageList';
                    this.columns = [
                        { title: "仓库名称123", dataIndex: "warehouseName" },
                        { title: "货位编码", width: 100, dataIndex: "code" },
                        { title: "货位名称", dataIndex: "name" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        warehouseId: this.wherehouseId
                    }
                    break;
                case 'inventoryCategory'://存货分类
                    this.apiUrl = '/in/inventoryCategory/getInventoryCategoryList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    this.pagination = false;
                    break;
                case 'invoiceType'://发票类型
                    this.apiUrl = '/erp/invoiceType/pageList';
                    this.columns = [
                        { title: "发票类型编码", dataIndex: "code", align: "left", width: 100 },
                        { title: "发票类型名称", dataIndex: "name", align: "left", width: 100 },
                        {
                            title: "方向",
                            dataIndex: "type",
                            align: "center",
                            width: 100,
                            customRender: (text) => {
                                return <span>{text == 1 ? "正发票" : "负发票"}</span>;
                            },
                        },
                        {
                            title: "税率",
                            dataIndex: "taxRate",
                            align: "center",
                            width: 100,
                            customRender: (text) => {
                                return text + "%";
                            },
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'contractPhase'://合同阶段
                    this.apiUrl = '/cm/contractStage/pageList';
                    this.columns = [
                        { title: "合同阶段编码", dataIndex: "code", align: "left", width: 100 },
                        { title: "合同阶段名称", dataIndex: "name", align: "left", width: 100 },
                        {
                            title: "是否保证金",
                            dataIndex: "isRetentionMoney",
                            align: "center",
                            width: 60,
                            customRender: (text) => {
                                return <span>{text == 1 ? "是" : "否"}</span>;
                            },
                        },
                        { title: "合同说明", dataIndex: "conetnet", align: "left", width: 100, }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        code: this.inputValue,
                    }
                    break;
                case 'contractTerms'://合同条款
                    this.apiUrl = '/cm/contractClause/getList';
                    this.columns = [
                        { title: "合同条款编码", dataIndex: "code", align: "left", width: 40 },
                        { title: "合同条款名称", dataIndex: "name", align: "left", width: 40 },
                        { title: "合同条款内容", dataIndex: "content", align: "left", width: 100, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        code: this.inputValue,
                    }
                    this.pagination = false;
                    break;
                case 'currency'://币种
                    this.apiUrl = '/erp/currency/pageList';
                    this.columns = [
                        { title: "编码", dataIndex: "code" },
                        { title: "币名", dataIndex: "name" },
                        { title: "币符号", dataIndex: "currencySign" },
                        {
                            title: "折算方式",
                            dataIndex: "calDirection",
                            customRender: (text, row, index) => {
                                return text == 1 ? "原币*汇率=本位币" : "原币/汇率=本位币";
                            },
                            ellipsis: true,
                        },
                        {
                            title: "汇率设置方式",
                            dataIndex: "exChangeRateType",
                            customRender: (text, row, index) => {
                                return text == 1 ? "日汇率" : "月汇率";
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'clearmethod'://结算方式
                    this.apiUrl = '/erp/settleStyle/pageList';
                    this.columns = [
                        { align: "left", title: "结算方式编码333", dataIndex: "code", width: "120" },
                        { align: "left", title: "结算方式名称", dataIndex: "name", width: "120" },
                        { align: "left", title: "默认账户", dataIndex: "bankAccount", width: "120" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        keyWord : this.inputValue,
                    }
                    break;
                case 'voucherCode'://业务对象
                    this.apiUrl = '/erp/voucherTable/listByDto';
                    this.columns = [
                        { align: "left", title: "业务对象编码", dataIndex: "voucherTypeCode", width: "120" },
                        { align: "left", title: "业务对象名称", dataIndex: "voucherTypeName", width: "120" },
                    ];
                    this.postData = {
                        name: this.inputValue,
                        code: this.inputValue,
                        // searchKey: this.inputValue,
                    }
                    this.pagination = false;
                    break;
                case 'voucherField'://业务对象字段
                    this.apiUrl = '/erp/voucherDesign/list';
                    this.columns = [
                        { align: "left", title: "字段code", dataIndex: "code", width: "120" },
                        {
                            align: "left", title: "字段名称", dataIndex: "name", width: "120", customRender: (text, record, index) => {
                                return record.dataTab + '-' + text
                            }
                        },
                    ];
                    this.postData = {
                        source: this.voucherCode,
                        name: this.inputValue,
                        code: this.inputValue,
                    }
                    this.pagination = false;
                    break;
                case 'barcodeAttrCode'://条码属性编码
                    this.apiUrl = '/barcode/attribute/getList';
                    this.columns = [
                        { align: "left", title: "字段code", dataIndex: "code", width: "120" },
                        { align: "left", title: "字段名称", dataIndex: "name", width: "120" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                    }
                    break;

                default:
                    break;
            }
        },
        //多选
        onSelectChange (keys, rows) {
            this.selectedKeys = keys;
            this.selectedRows = rows;
            console.log(keys, rows);

        },
        handleClick () {
            // if (this.selectedRows.length < 1) {
            //     this.$message.warning('请选择限制科目');
            //     return;
            // } else {
            this.$emit('clickItem', this.selectedRows);
            // }
        },
        rowClassName (record, index) {
            return record.isEndNode === false ? 'background-c' : '';
        },
    }
}
</script>
<style lang="less">
    .details-search-wrapper {
        .search-wrapper {
            max-height: 350px;
            box-shadow: 2px 2px 10px 2px #e0e0e0;
            position: fixed;
            z-index: 10016;
            border: 1px solid #a7abb0;
            width: 500px;
        }
        // .ant-table-wrapper .ant-table-placeholder {
        //   position: static !important;
        //   top: 0;
        // }
        .ant-table-wrapper {
            background: #eee;
        }
        .ant-table-tbody {
            cursor: pointer;
        }
    }
    .much-table {
        transform: translateZ(0);
        .ant-table-footer {
            padding: 0;
        }
        .much-footer {
            text-align: right;
            position: fixed;
            z-index: 12;
            right: 13px;
            bottom: 5px;
        }
    }
    .background-c {
        background: #cccccc;
    }
</style>